/**
 * Licensee: andres orellana
 * License Type: Evaluation
 */
package ormsamples;

import org.orm.*;
public class ListPinPassData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
		System.out.println("Listing Coordenada...");
		orm.Coordenada[] ormCoordenadas = lDAOFactory.getCoordenadaDAO().listCoordenadaByQuery(null, null);
		int length = Math.min(ormCoordenadas.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormCoordenadas[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Log...");
		orm.Log[] ormLogs = lDAOFactory.getLogDAO().listLogByQuery(null, null);
		length = Math.min(ormLogs.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormLogs[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Cliente...");
		orm.Cliente[] ormClientes = lDAOFactory.getClienteDAO().listClienteByQuery(null, null);
		length = Math.min(ormClientes.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormClientes[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Coordenada by Criteria...");
		orm.CoordenadaCriteria coordenadaCriteria = new orm.CoordenadaCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//coordenadaCriteria.id.eq();
		coordenadaCriteria.setMaxResults(ROW_COUNT);
		orm.Coordenada[] ormCoordenadas = coordenadaCriteria.listCoordenada();
		int length =ormCoordenadas== null ? 0 : Math.min(ormCoordenadas.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormCoordenadas[i]);
		}
		System.out.println(length + " Coordenada record(s) retrieved."); 
		
		System.out.println("Listing Log by Criteria...");
		orm.LogCriteria logCriteria = new orm.LogCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//logCriteria.log_id.eq();
		logCriteria.setMaxResults(ROW_COUNT);
		orm.Log[] ormLogs = logCriteria.listLog();
		length =ormLogs== null ? 0 : Math.min(ormLogs.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormLogs[i]);
		}
		System.out.println(length + " Log record(s) retrieved."); 
		
		System.out.println("Listing Cliente by Criteria...");
		orm.ClienteCriteria clienteCriteria = new orm.ClienteCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//clienteCriteria.cli_id.eq();
		clienteCriteria.setMaxResults(ROW_COUNT);
		orm.Cliente[] ormClientes = clienteCriteria.listCliente();
		length =ormClientes== null ? 0 : Math.min(ormClientes.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormClientes[i]);
		}
		System.out.println(length + " Cliente record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListPinPassData listPinPassData = new ListPinPassData();
			try {
				listPinPassData.listTestData();
				//listPinPassData.listByCriteria();
			}
			finally {
				orm.PinPassPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
